package com.lkd.shoppingcart.dao.impl;

import com.lkd.shoppingcart.dao.UserDao;
import com.lkd.shoppingcart.entity.User;

public class UserDaoImpl extends BaseDao implements UserDao {
	
	@Override
	public int addUser(User user) {
        String sql = "insert into user(name, password) values(?,?)";
        return update(sql, user.getName(),user.getPassword());
	}

	@Override
	public User queryByName(String name) {
		String sql = "select id, name, password from user where name = ?";
        return queryForOne(User.class, sql, name);
	}

	@Override
	public User queryByNameAndPassword(String name, String password) {
		String sql = "select id, name, password from user where name = ? and password = ?";
        return queryForOne(User.class, sql, name, password);
	}

}
